﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using hotel.DAL;
using System.Xml.Linq;
namespace hotel.Win
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            System.Drawing.Pen myPen = new System.Drawing.Pen(System.Drawing.Color.Red);
            System.Drawing.Graphics formGraphics;
            formGraphics = panel1.CreateGraphics();
            formGraphics.DrawLine(myPen, 0, 0, panel1.Width, 0);
            formGraphics.DrawLine(myPen, 0, 0, 0, panel1.Height);
            formGraphics.DrawLine(myPen, 0, panel1.Height-5, panel1.Width-5, panel1.Height-5);
            formGraphics.DrawLine(myPen, panel1.Width-5, panel1.Height-5, panel1.Width-5, 0);
            myPen.Dispose();
            formGraphics.Dispose();

            //var _c = new hotel.DAL.hotelEntities();
            //int i = _c.XTCYDM.Where(p => Convert.ToDateTime(p.CJRQ).ToString("yyyy-MM-dd") == "2010-05-11").Count();
            //string entitySQL = "select value a from xtcydm as a where convert(varchar(10),a.cjrq,120)=convert(varchar(10),getdate(),120)";
            //var query = _c.CreateQuery<XTCYDM>(entitySQL);
            //var query = from p in _c.XTCYDM
            //            where p.LBDM.Substring(0,1) == "L"
            //            select p;
  
            //MessageBox.Show(query.Count().ToString());
           

        }

        private void button2_Click(object sender, EventArgs e)
        {
            //var frm = new Subscribe.jddjFrm(new hotelEntities().ROOM.First(p=>p.ID=="1004"),1);
            //frm.Show();
        }

        private void panel1_DoubleClick(object sender, EventArgs e)
        {
            MessageBox.Show("Test");
        }

        private void button3_Click(object sender, EventArgs e)
        {
            System.IO.FileInfo FileInfo = new System.IO.FileInfo(@"C:\人和酒店系统\hotel.Win.exe.config");
            //实例化xml文档
            System.Xml.XmlDocument XmlDocument = new System.Xml.XmlDocument();
            XmlDocument.Load(FileInfo.FullName);
            //查找到appsettings中的节点
            System.Xml.XmlNode Node;
            //bool FoundIt = false;            
            foreach (System.Xml.XmlNode tempLoopVar_Node in XmlDocument["configuration"]["log4net"]["appender"])
            {
               
                Node = tempLoopVar_Node;
               
                if (Node.Name == "connectionString")
                {
                        Node.Attributes.GetNamedItem("value").Value = "fffffffffffffffffffff";
                       // FoundIt = true;                    
                }
            }
            XmlDocument.Save(@"C:\人和酒店系统\hotel.Win.exe.config");
        }

        private void button4_Click(object sender, EventArgs e)
        {
            var datas = from test in XElement.Load("IdentityCardDatas.xml").Elements("data")
                        select new
                        {
                            Key = test.Attribute("key").Value,
                            Value = test.Attribute("value").Value
                        };
            MessageBox.Show(datas.Count().ToString());
            //foreach (var item in datas)
            //{
            //    areaInfo.Add(item.Key, item.Value);
            //}
        }
    }
}
